var inputUrl = basePath + "/sys/report/schoolProperty/inputRecord";

var dataGrid;
$(function() {
	loadData();
});

function loadData() {
	dataGrid = $('#notice').datagrid({
		url : inputUrl,
		toolbar: '#tb',
		fit : true,
		fitColumns : true,
		border : true,
		pagination : true,
		idField : 'id',
		pageSize : config.pageSize,
		autoRowHeight : 140,
		pageList : config.pageList,
		queryParams : {
			startTimeText: $("#startTimeText").val(),
			endTimeText:  $("#endTimeText").val()
		},
		nowrap : true,
		striped : true,
		rownumbers : true,
		columns : [[ 
			{
			field : 'id',
			width : 10,
			align : "center",
			checkbox : true
		},
		{ 
			field : 'no',
			title : '批次号',
			resizable : true,
			align : "center",
			width : 15
		}, 
		{
			field : 'typeName',
			title : '类别名称',
			width : 15,
			align : "center"
		}, 
		{
			field : 'goodsName',
			title : '物品名称',
			width : 15,
			align : "center"
		}, 
		{
			field : 'goodsAttr',
			title : '型号',
			width : 15,
			align : "center"
		}, 
		{
			field : 'number',
			title : '数量',
			width : 15,
			align : "center"
		}, 
		{
			field : 'price',
			title : '单价',
			width : 10,
			align : "center"
		}, 
		{
			field : 'totalMoney',
			title : '总价',
			width : 10,
			align : "center"
		}, 
		{
			field : 'operatorName',
			align : 'center',
			title : '操作人',
			width : 20
        }, 
		{
			field : 'buyTime',
			title : '购买时间',
			width : 10,
			align : "center"
		},
		{
			field : 'createTimeText',
			title : '入库时间',
			width : 15,
			align : "center"
		}
        ]],
		onAfterEdit : function(rowIndex, rowData, changes){
			if(rowData.id){
				changes.id = rowData.id;
				changes.resourceRange = $("#resourceRange").val();
				addmodify(changes);
			}else {
				rowData.resourceRange = $("#resourceRange").val();
				addmodify(rowData);
			}
		}
	});
}

function exportToExcel(searchForm,exportUrl) {
	$("#" + searchForm).attr('action',exportUrl); 
	$("#" + searchForm).submit();  
}

function reload() {
	dataGrid.datagrid("clearSelections");
	searchForm("searchForm");
}

function searchForm(formId) {
	dataGrid.datagrid('load', $.serializeObject($('#' + formId)));
}
function resetForm(formId) {
	$("#" + formId)[0].reset();
	$("#startTimeText").datebox('setValue','');
	$("#endTimeText").datebox('setValue','');
}